package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.Hudongleixing;
import com.ruoyi.system.service.IHudongleixingService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Shangjiabaoming;
import com.ruoyi.system.service.IShangjiabaomingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商家报名活动Controller
 * 
 * @author ruoyi
 * @date 2024-08-10
 */
@RestController
@RequestMapping("/system/shangjiabaoming")
public class ShangjiabaomingController extends BaseController
{
    @Autowired
    private IShangjiabaomingService shangjiabaomingService;
    @Autowired
    private IHudongleixingService hudongleixingService;

    /**
     * 查询商家报名活动列表
     */
    @PreAuthorize("@ss.hasPermi('system:shangjiabaoming:list')")
    @GetMapping("/list")
    public TableDataInfo list(Shangjiabaoming shangjiabaoming)
    {
        startPage();
        List<Shangjiabaoming> list = shangjiabaomingService.selectleixingname(shangjiabaoming);
        return getDataTable(list);
    }

    @GetMapping("/hdlxname")
    public TableDataInfo hdlxname(Hudongleixing hudongleixing)
    {
        List<Hudongleixing> list = hudongleixingService.hudongleixinglist(hudongleixing);
        return getDataTable(list);
    }

    /**
     * 导出商家报名活动列表
     */
    @PreAuthorize("@ss.hasPermi('system:shangjiabaoming:export')")
    @Log(title = "商家报名活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Shangjiabaoming shangjiabaoming)
    {
        List<Shangjiabaoming> list = shangjiabaomingService.selectShangjiabaomingList(shangjiabaoming);
        ExcelUtil<Shangjiabaoming> util = new ExcelUtil<Shangjiabaoming>(Shangjiabaoming.class);
        util.exportExcel(response, list, "商家报名活动数据");
    }

    /**
     * 获取商家报名活动详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:shangjiabaoming:query')")
    @GetMapping(value = "/{sjbmHdid}")
    public AjaxResult getInfo(@PathVariable("sjbmHdid") Long sjbmHdid)
    {
        return success(shangjiabaomingService.selectShangjiabaomingBySjbmHdid(sjbmHdid));
    }

    /**
     * 新增商家报名活动
     */
    @PreAuthorize("@ss.hasPermi('system:shangjiabaoming:add')")
    @Log(title = "商家报名活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Shangjiabaoming shangjiabaoming)
    {
        return toAjax(shangjiabaomingService.insertShangjiabaoming(shangjiabaoming));
    }

    /**
     * 修改商家报名活动
     */
    @PreAuthorize("@ss.hasPermi('system:shangjiabaoming:edit')")
    @Log(title = "商家报名活动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Shangjiabaoming shangjiabaoming)
    {
        return toAjax(shangjiabaomingService.updateShangjiabaoming(shangjiabaoming));
    }

    /**
     * 删除商家报名活动
     */
    @PreAuthorize("@ss.hasPermi('system:shangjiabaoming:remove')")
    @Log(title = "商家报名活动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sjbmHdids}")
    public AjaxResult remove(@PathVariable Long[] sjbmHdids)
    {
        return toAjax(shangjiabaomingService.deleteShangjiabaomingBySjbmHdids(sjbmHdids));
    }
}
